<?php
/**
 * | @author 韩威兵^life <1877361302@qq.com>
 * +----------------------------------------------------------------------
 * | @copyright 2016 - 2019 HQ
 * +----------------------------------------------------------------------
 * | @version $Id: 2019/5/4 10:53 jiahe_new storeServer.php 韩威兵^life $
 * +----------------------------------------------------------------------
 */

namespace app\api\server;

use app\common\common\Server\verifiableServer;

class  storeServer{
    /**
     * 判断是否是早餐时间
     * @param $store_id
     * @return bool
     */
    public function isMorning($store_id= ''){
        $special_store_breakfast = config('special_store_breakfast');
        $now_time = date('H:i');
//        $now_time = '06:50';

        //判断如果是特殊门店，早餐
        if(array_key_exists($store_id, $special_store_breakfast)){
            $start_time = $special_store_breakfast[$store_id]['start'];
            $end_time = $special_store_breakfast[$store_id]['end'];
        }else{
            $default_breakfast = config('default_breakfast');
            $now_w = verifiableServer::isWeekend(time());
            $start_time = $default_breakfast[$now_w]['start'];
            $end_time = $default_breakfast[$now_w]['end'];
        }

        if($now_time >= $start_time && $now_time <= $end_time){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 判断有没有特殊粥料，特殊粥料不能使用早餐卡
     * @param $json_classify
     * @return bool
     */
    public function isSpecialClassify($json_classify){
        $arr = json_decode($json_classify, true);
        if(empty($arr)){
            return false;
        }
        $special_goods_status = config('special_goods_status');
        foreach ($arr as $k=>$v){
            if(array_key_exists($v, $special_goods_status)){
                return false;
            }
        }
        return true;
    }
}  